Method: Vips::Image#[]

Defined in:
lib/vips8/image.rb

#[](index) ⇒ Image

Fetch bands using a number or a range

Parameters:

  • index (Numeric, Range)

    extract these band(s)

Returns:

  • (Image)

    extracted band(s)


918
919
920
921
922
923
924
925
926
927
928
# File 'lib/vips8/image.rb', line 918

def [](index)
    if index.is_a? Range
        n = index.end - index.begin
        n += 1 if not index.exclude_end?
        extract_band index.begin, :n => n
    elsif index.is_a? Numeric
        extract_band index 
    else
        raise Vips::Error, "[] index is not range or numeric."
    end
end